using System.Collections.Generic;
using System.Text;
using System.Text.Json.Serialization;

namespace ConsentManagementProviderLib
{
	public class GdprConsent
	{
		[JsonInclude]
		public bool applies;

		[JsonInclude]
		public string uuid;

		[JsonInclude]
		public string webConsentPayload;

		[JsonInclude]
		public string euconsent;

		[JsonInclude]
		public Dictionary<string, object> TCData;

		[JsonInclude]
		public Dictionary<string, SpVendorGrant> grants;

		[JsonInclude]
		public List<string> acceptedCategories;

		[JsonInclude]
		public ConsentStatus consentStatus;

		public string ToFullString()
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendLine("UUID: " + uuid);
			stringBuilder.AppendLine("EUConsent: " + euconsent);
			stringBuilder.AppendLine($"Applies: {applies}");
			stringBuilder.AppendLine("WebConsentPayload: " + webConsentPayload);
			if (TCData != null)
			{
				stringBuilder.AppendLine("TCData:");
			}
			if (grants != null)
			{
				stringBuilder.AppendLine("Grants:");
				foreach (KeyValuePair<string, SpVendorGrant> grant in grants)
				{
					stringBuilder.AppendLine("    Vendor: " + grant.Key);
					stringBuilder.AppendLine($"    VendorGrant: {grant.Value.vendorGrant}");
					if (grant.Value.purposeGrants == null)
					{
						continue;
					}
					stringBuilder.AppendLine("    Purpose Grants:");
					foreach (KeyValuePair<string, bool> purposeGrant in grant.Value.purposeGrants)
					{
						stringBuilder.AppendLine($"        {purposeGrant.Key}: {purposeGrant.Value}");
					}
				}
			}
			if (acceptedCategories != null)
			{
				stringBuilder.AppendLine("Accepted Categories:");
				foreach (string acceptedCategory in acceptedCategories)
				{
					stringBuilder.AppendLine("    " + acceptedCategory);
				}
			}
			return stringBuilder.ToString();
		}
	}
}
